<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<body>
    <button>点击</button>
    <script>
        function throttle(callback,delay){
            let timer=null

            return function(...rest){
                if(timer) return 
                timer=setInterval(()=>{
                    callback.apply(this,rest)
                    clearInterval(timer)
                },delay)
            }
        }

        // 测试
        let btn=document.querySelector('button')
        btn.onclick=throttle(function(){
            console.log(this);
            console.log(this.innerText);
        },2000)
    </script>
</body>
</body>
</html>